package cn.goktech.sports.modules.countryEmbargoGoods.service.impl;

import cn.goktech.sports.modules.countryEmbargoGoods.dao.CountryEmbargoGoodsMapper;
import cn.goktech.sports.modules.countryEmbargoGoods.entity.ImportEntity;
import cn.goktech.sports.modules.countryEmbargoGoods.service.CountryEmbargoGoodsService;
import cn.goktech.sports.modules.importDataone.dao.ImportDataoneMapper;
import cn.goktech.sports.modules.importDataone.entity.BaseProhibited;
import cn.goktech.sports.modules.importDataone.entity.ProductType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 模板一数据
 *
 * @author ZhouChenglin<yczclcn @ 1 6 3 . com>
 */
@Service("countryEmbargoGoodsService")
public class CountryEmbargoGoodsServiceImpl implements CountryEmbargoGoodsService {

    @Autowired
    private CountryEmbargoGoodsMapper countryEmbargoGoodsMapper;

    @Autowired
    private ImportDataoneMapper importDataoneMapper;

    @Override
    public int isExist(String countryId, String goodsName) {
        return countryEmbargoGoodsMapper.isExist(countryId, goodsName);
    }

    @Override
    public void insert(List<ImportEntity> list) {
        countryEmbargoGoodsMapper.insert(list);
    }

    @Override
    public void delete(Long articleTypeId) {
        countryEmbargoGoodsMapper.delete(articleTypeId);
    }

    @Override
    public Map<String, Long> getProductMap() {
        List<ProductType> productTypeList = importDataoneMapper.getProductList();
        Map<String,Long> productMap=new HashMap<>();
        for (int i = 0; i < productTypeList.size(); i++) {
            productMap.put(productTypeList.get(i).getProductName(), productTypeList.get(i).getId());
        }
        return productMap;
    }

    @Override
    public List<BaseProhibited> contraband(Map<String, Object> params) {
        return countryEmbargoGoodsMapper.contraband(params);
    }
}
